//
//  HaokaMiddleHeaderView.m
//  BMProject
//
//  Created by chris on 16/1/2.
//  Copyright © 2016年 BMProject. All rights reserved.
//

#import "HaokaMiddleHeaderView.h"

@interface HaokaMiddleHeaderView() <UITextFieldDelegate> {

}
@end

@implementation HaokaMiddleHeaderView

- (void)awakeFromNib {
    [super awakeFromNib];
    _haoduanTF.delegate = self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

#pragma mark UITextFieldDelegate 限制TextField位数的代理方法 12为
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
    // 工单号
    if (textField == _haoduanTF) {
        NSString * toBeString = [textField.text stringByReplacingCharactersInRange:range withString:string];
        if (toBeString.length > 11 && range.length!=1){ //最大11个字符
            textField.text = [toBeString substringToIndex:11];
            return NO;
        }
        if ([string chenkInputNSCharacterSetWithType:2])//kNumbers
        {
            return YES;
        }
        else
            return NO;
    }
    return YES;
}

@end
